package com.example.shushiyunsst.fragment.main.transaction.child.content

import android.os.Bundle
import android.view.View
import com.example.library_common.base.BaseFragmentEx
import com.example.library_common.base.LazyFragment
import com.example.shushiyunsst.R
import com.example.shushiyunsst.fragment.main.transaction.bean.TransactionUIInvokeListener
import com.example.shushiyunsst.fragment.main.transaction.child.TransactionContentFragment

class TransactionContentHeaderFragment : LazyFragment() {

    companion object {
        fun newInstance(): TransactionContentHeaderFragment {
            val args = Bundle()

            val fragment = TransactionContentHeaderFragment()
            fragment.arguments = args
            return fragment
        }
    }


    private var transactionUIInvokeListener: TransactionUIInvokeListener?=null

    fun setTransactionUIInvokeListener(listener: TransactionUIInvokeListener?): BaseFragmentEx {
        this.transactionUIInvokeListener=listener
        return this
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mSuperBackPressedSupport = false
    }

    override fun getLayoutId() = R.layout.transaction_content_header_fragment

    override fun initView(view: View) {
        val transactionSetting=TransactionSettingFragment.newInstance()
            .setTransactionUIInvokeListener(transactionUIInvokeListener)
        loadRootFragment(R.id.transactionSetting, transactionSetting)


        val newInstance = TransactionCurrentTendencyFragment.newInstance()
        newInstance.setTransactionSettingInvoker(transactionSetting)
        newInstance.setTransactionUIInvokeListener(transactionUIInvokeListener)
        loadRootFragment(
            R.id.transactionCurrentTendency,
            newInstance
        )
    }

    override fun lazyInit() {

    }

    override fun onDestroy() {
        super.onDestroy()
        transactionUIInvokeListener=null
    }

}